-- Copyright (c) 2024 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at:
--          http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.
local validate = require 'mc.validate'
local utils = require 'mc.utils'

local MCoolingFan = {}

---@class MCoolingFan.MaxSupportedPWM
---@field MaxSupportedPWM integer
local TMaxSupportedPWM = {}
TMaxSupportedPWM.__index = TMaxSupportedPWM
TMaxSupportedPWM.group = {}

local function TMaxSupportedPWM_from_obj(obj)
    return setmetatable(obj, TMaxSupportedPWM)
end

function TMaxSupportedPWM.new(MaxSupportedPWM)
    return TMaxSupportedPWM_from_obj({MaxSupportedPWM = MaxSupportedPWM})
end
---@param obj MCoolingFan.MaxSupportedPWM
function TMaxSupportedPWM:init_from_obj(obj)
    self.MaxSupportedPWM = obj.MaxSupportedPWM
end

function TMaxSupportedPWM:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TMaxSupportedPWM.group)
end

TMaxSupportedPWM.from_obj = TMaxSupportedPWM_from_obj

TMaxSupportedPWM.proto_property = {'MaxSupportedPWM'}

TMaxSupportedPWM.default = {0}

TMaxSupportedPWM.struct = {{name = 'MaxSupportedPWM', is_array = false, struct = nil}}

function TMaxSupportedPWM:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'MaxSupportedPWM', self.MaxSupportedPWM, 'uint32', false, errs, need_convert)

    TMaxSupportedPWM:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TMaxSupportedPWM.proto_property, errs, need_convert)
    return self
end

function TMaxSupportedPWM:unpack(_)
    return self.MaxSupportedPWM
end

MCoolingFan.MaxSupportedPWM = TMaxSupportedPWM

---@class MCoolingFan.Slot
---@field Slot integer
local TSlot = {}
TSlot.__index = TSlot
TSlot.group = {}

local function TSlot_from_obj(obj)
    return setmetatable(obj, TSlot)
end

function TSlot.new(Slot)
    return TSlot_from_obj({Slot = Slot})
end
---@param obj MCoolingFan.Slot
function TSlot:init_from_obj(obj)
    self.Slot = obj.Slot
end

function TSlot:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TSlot.group)
end

TSlot.from_obj = TSlot_from_obj

TSlot.proto_property = {'Slot'}

TSlot.default = {0}

TSlot.struct = {{name = 'Slot', is_array = false, struct = nil}}

function TSlot:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Slot', self.Slot, 'uint8', false, errs, need_convert)

    TSlot:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TSlot.proto_property, errs, need_convert)
    return self
end

function TSlot:unpack(_)
    return self.Slot
end

MCoolingFan.Slot = TSlot

return MCoolingFan
